package com.jiang.common;

/**
 * http请求返回的最外层对
 */
public class ResultTO<T> {

	/**
	 * 状态码
	 */
	private String code;

	/**
	 * 提示信息
	 */
	private String msg;

	/**
	 * 具体内容
	 */
	private T data;

	public static <T> ResultTO<T> success(T data) {
		ResultTO<T> resultVO = new ResultTO<T>();
		resultVO.setData(data);
		resultVO.setCode(StatusEnum.SUCCESS.getCode());
		resultVO.setMsg("成功");
		return resultVO;
	}

	public static <T> ResultTO<T> fail(StatusEnum statusEnum, String msg) {
		ResultTO<T> response = new ResultTO<>();
		response.setCode(statusEnum.getCode());
		response.setMsg(msg);
		return response;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}
